#include <bits/stdc++.h>
#define re register
#define Add(a,b) (((a) + (b)) % mod)
#define chAdd(a,b) (a = Add(a,b))

using namespace std;

const int N = 2e5 + 10;
int n,mod;
int dp[N];

inline int read(){
    int r = 0,w = 1;
    char c = getchar();
    while (c < '0' || c > '9'){
        if (c == '-') w = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9'){
        r = (r << 3) + (r << 1) + (c ^ 48);
        c = getchar();
    }
    return r * w;
}

inline void init(int n){
    dp[0] = 1;
    for (re int i = 1;i <= n;i += 2){
        for (re int j = n;j >= i;j--) chAdd(dp[j],dp[j - i]);
    }
}

inline void solve(){
    printf("%d\n",dp[read()]);
}

int main(){
    freopen("moon.in","r",stdin);
    freopen("moon.out","w",stdout);
    int T = read(); mod = read();
    init(3e3);
    while (T--) solve();
    return 0;
}